//
//  BVCommunityDetailCell1.m
//  XiangYu
//
//  Created by YYKJ on 2017/8/7.
//  Copyright © 2017年 YYKJ. All rights reserved.
//

#import "BVCommunityDetailCell1.h"

@implementation BVCommunityDetailCell1

-(void)makeSubViews{
    
    self.avatar = [[UIImageView alloc]init];
    [self.contentView addSubview:self.avatar];
    [UIView makeCorner:25.0 view:self.avatar];
    self.avatar.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(50)
    .heightEqualToWidth();
    
    self.timeLb = [[UILabel alloc]init];
    [self.contentView addSubview:self.timeLb];
    [self.timeLb setTextColor:[UIColor BVTextGrayColor]];
    [self.timeLb setFont:[UIFont systemFontOfSize:14]];
    self.timeLb.sd_layout
    .topSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .widthIs(80)
    .heightIs(20);
    
    self.nickNameLb = [[UILabel alloc]init];
    [self.contentView addSubview:self.nickNameLb];
    [self.nickNameLb setTextColor:[UIColor BVTextDarkGrayColor]];
    [self.nickNameLb setFont:[UIFont systemFontOfSize:16]];
    self.nickNameLb.sd_layout
    .topSpaceToView(self.contentView, 10)
    .leftSpaceToView(self.avatar, 10)
    .rightSpaceToView(self.timeLb, 10)
    .heightIs(20);
    
    self.contentLb = [[UILabel alloc]init];
    [self.contentView addSubview:self.contentLb];
    [self.contentLb setFont:[UIFont systemFontOfSize:14.0]];
    [self.contentLb setTextColor:[UIColor BVTextGrayColor]];
    self.contentLb.sd_layout
    .topSpaceToView(self.nickNameLb, 10)
    .leftSpaceToView(self.avatar, 10)
    .rightSpaceToView(self.contentView, 15)
    .autoHeightRatio(0);
    
    self.photosContainer = [[PhotosContainerView alloc] initWithMaxItemsCount:9];
    [self.contentView addSubview:self.photosContainer];
    _photosContainer.sd_layout
    .leftEqualToView(self.contentLb)
    .rightEqualToView(self.contentLb)
    .topSpaceToView(self.contentLb, 10);
    
}

-(UIButton *)buttonWithTitle:(NSString *)title WithImageName:(NSString *)imageName{
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor BVTextGrayColor] forState:UIControlStateNormal];
    return btn;
}

- (void)setModel:(DemoVC7Model *)model{
    _model = model;
    
    [self.avatar setImage:[UIImage imageNamed:model.iconImagePath]];
    [self.timeLb setText:@"2017.05.09"];
    [self.nickNameLb setText:@"中国测试测试网"];
    [self.contentLb setText:model.title];
    
    UIView *bottomView = _photosContainer;
    _photosContainer.photoNamesArray = model.imagePathsArray;
    if (model.imagePathsArray.count > 0) {
        _photosContainer.hidden = NO;
        bottomView = _photosContainer;
        _photosContainer.sd_layout.autoHeightRatio(0);
    } else {
        _photosContainer.hidden = YES;
        _photosContainer.sd_layout.heightIs(0);
    }
    NSLog(@"---------%f",_photosContainer.height);
    [self setupAutoHeightWithBottomViewsArray:@[_photosContainer,self.contentLb,] bottomMargin:10.0];
    
}

@end
